package graphics;

import java.awt.Color;

public class Plane extends Polygon {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public Plane(Vector V1, Vector V2, Vector V3) {
		this.add(V1);
		this.add(V2);
		this.add(V3);
	}
	private	Color	lineColor	= Color.black;
	private	Color	fillColor	= Color.red;
	
	public	Vector	getA()			{	return this.get(0);	}
	public	Vector	getB()			{	return this.get(1);	}
	public	Vector	getC()			{	return this.get(2);	}
	
	public boolean	isWire()		{	return (getA().equiv(getC()) || getA().equiv(getB()) || getB().equiv(getC()));	}
	
	public	Vector	getCenter()		{
		return new Vector(
			(getA().getX() + getB().getX() + getC().getX())/3f,
			(getA().getY() + getB().getY() + getC().getY())/3f,
			(getA().getZ() + getB().getZ() + getC().getZ())/3f
		);
	}
	
	public	Vector	getMinBounds() {
		return new Vector(
			Math.min(getA().getX(),	Math.min(getB().getX(), getC().getX())),
			Math.min(getA().getY(),	Math.min(getB().getY(), getC().getY())),
			Math.min(getA().getZ(),	Math.min(getB().getZ(), getC().getZ()))
		);
	}
	
	public	Vector	getMaxBounds() {
		return new Vector(
			Math.max(getA().getX(),	Math.max(getB().getX(), getC().getX())),
			Math.max(getA().getY(),	Math.max(getB().getY(), getC().getY())),
			Math.max(getA().getZ(),	Math.max(getB().getZ(), getC().getZ()))
		);
	}	
	
	public	void	setA(Vector V)	{	this.set(0,V);		}
	public	void	setB(Vector V)	{	this.set(1,V);		}
	public	void	setC(Vector V)	{	this.set(2,V);		}
	
	public Color getLineColor() {
		return lineColor;
	}
	public void setLineColor(Color lineColor) {
		this.lineColor = lineColor;
	}
	public Color getFillColor() {
		return fillColor;
	}
	public void setFillColor(Color fillColor) {
		this.fillColor = fillColor;
	}
}
